From daff910c6c48ad61c7b759880548a883295d0e17 Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Mon, 14 Aug 2006 14:17:26 +0100 Subject: [PATCH] [XENBUS] Avoid direct use of xen_start_info. It's unevailable when building as a separate driver for an HVM guest. Signed-off-by: Steven Smith Signed-off-by: Keir Fraser --- .../drivers/xen/xenbus/xenbus_comms.c | 15 ++++-------- .../drivers/xen/xenbus/xenbus_comms.h | 2 ++ .../drivers/xen/xenbus/xenbus_dev.c | 2 +- .../drivers/xen/xenbus/xenbus_probe.c | 24 ++++++++++++------- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c index c1c1ef827d..38da320b67 100644 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c @@ -47,11 +47,6 @@ static DECLARE_WORK(probe_work, xenbus_probe, NULL); DECLARE_WAIT_QUEUE_HEAD(xb_waitq); -static inline struct xenstore_domain_interface *xenstore_domain_interface(void) -{ - return mfn_to_virt(xen_start_info->store_mfn); -} - static irqreturn_t wake_waiting(int irq, void *unused, struct pt_regs *regs) { if (unlikely(xenstored_ready == 0)) { @@ -90,7 +85,7 @@ static const void *get_input_chunk(XENSTORE_RING_IDX cons, int xb_write(const void *data, unsigned len) { - struct xenstore_domain_interface *intf = xenstore_domain_interface(); + struct xenstore_domain_interface *intf = xen_store_interface; XENSTORE_RING_IDX cons, prod; int rc; @@ -129,7 +124,7 @@ int xb_write(const void *data, unsigned len) intf->req_prod += avail; /* This implies mb() before other side sees interrupt. */ - notify_remote_via_evtchn(xen_start_info->store_evtchn); + notify_remote_via_evtchn(xen_store_evtchn); } return 0; @@ -137,7 +132,7 @@ int xb_write(const void *data, unsigned len) int xb_read(void *data, unsigned len) { - struct xenstore_domain_interface *intf = xenstore_domain_interface(); + struct xenstore_domain_interface *intf = xen_store_interface; XENSTORE_RING_IDX cons, prod; int rc; @@ -180,7 +175,7 @@ int xb_read(void *data, unsigned len) pr_debug("Finished read of %i bytes (%i to go)\n", avail, len); /* Implies mb(): they will see new header. */ - notify_remote_via_evtchn(xen_start_info->store_evtchn); + notify_remote_via_evtchn(xen_store_evtchn); } return 0; @@ -195,7 +190,7 @@ int xb_init_comms(void) unbind_from_irqhandler(xenbus_irq, &xb_waitq); err = bind_evtchn_to_irqhandler( - xen_start_info->store_evtchn, wake_waiting, + xen_store_evtchn, wake_waiting, 0, "xenbus", &xb_waitq); if (err <= 0) { printk(KERN_ERR "XENBUS request irq failed %i\n", err); diff --git a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.h b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.h index 42f97f5d8c..9599d037c4 100644 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.h +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.h @@ -39,5 +39,7 @@ int xb_write(const void *data, unsigned len); int xb_read(void *data, unsigned len); int xs_input_avail(void); extern wait_queue_head_t xb_waitq; +extern struct xenstore_domain_interface *xen_store_interface; +extern int xen_store_evtchn; #endif /* _XENBUS_COMMS_H */ diff --git a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c index 02d3b46ee7..6e30040779 100644 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c @@ -285,7 +285,7 @@ static int xenbus_dev_open(struct inode *inode, struct file *filp) { struct xenbus_dev_data *u; - if (xen_start_info->store_evtchn == 0) + if (xen_store_evtchn == 0) return -ENOENT; nonseekable_open(inode, filp); diff --git a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c index 9d350cad99..a8b9391e08 100644 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c @@ -54,6 +54,10 @@ #include "xenbus_comms.h" +int xen_store_evtchn; +struct xenstore_domain_interface *xen_store_interface; +static unsigned long xen_store_mfn; + extern struct mutex xenwatch_mutex; static struct notifier_block *xenstore_chain; @@ -928,8 +932,7 @@ static int xsd_kva_mmap(struct file *file, struct vm_area_struct *vma) if ((size > PAGE_SIZE) || (vma->vm_pgoff != 0)) return -EINVAL; - if (remap_pfn_range(vma, vma->vm_start, - mfn_to_pfn(xen_start_info->store_mfn), + if (remap_pfn_range(vma, vma->vm_start, mfn_to_pfn(xen_store_mfn), size, vma->vm_page_prot)) return -EAGAIN; @@ -941,7 +944,7 @@ static int xsd_kva_read(char *page, char **start, off_t off, { int len; - len = sprintf(page, "0x%p", mfn_to_virt(xen_start_info->store_mfn)); + len = sprintf(page, "0x%p", xen_store_interface); *eof = 1; return len; } @@ -951,13 +954,12 @@ static int xsd_port_read(char *page, char **start, off_t off, { int len; - len = sprintf(page, "%d", xen_start_info->store_evtchn); + len = sprintf(page, "%d", xen_store_evtchn); *eof = 1; return len; } #endif - static int __init xenbus_probe_init(void) { int err = 0, dom0; @@ -985,7 +987,7 @@ static int __init xenbus_probe_init(void) if (!page) return -ENOMEM; - xen_start_info->store_mfn = + xen_store_mfn = xen_start_info->store_mfn = pfn_to_mfn(virt_to_phys((void *)page) >> PAGE_SHIFT); @@ -998,7 +1000,8 @@ static int __init xenbus_probe_init(void) if (err == -ENOSYS) goto err; BUG_ON(err); - xen_start_info->store_evtchn = alloc_unbound.port; + xen_store_evtchn = xen_start_info->store_evtchn = + alloc_unbound.port; #ifdef CONFIG_PROC_FS /* And finally publish the above info in /proc/xen */ @@ -1014,8 +1017,13 @@ static int __init xenbus_probe_init(void) if (xsd_port_intf) xsd_port_intf->read_proc = xsd_port_read; #endif - } else + } else { xenstored_ready = 1; + xen_store_evtchn = xen_start_info->store_evtchn; + xen_store_mfn = xen_start_info->store_mfn; + } + + xen_store_interface = mfn_to_virt(xen_store_mfn); /* Initialize the interface to xenstore. */ err = xs_init(); -- 2.30.2